/**
 * @description  权益行业风险分析
 * @author zls
 */
import React, { PureComponent } from 'react';
import { message, Select } from 'antd';
import { connect } from 'dva';
import IndustryExposureDetail from './IndustryExposureDetail'; //行业敞口明细
import ProductAndBenchmarkIndustryExposure from './ProductAndBenchmarkIndustryExposure'; //产品与基准行业敞口
import ProfitAnalysis from './ProfitAnalysis'; //收益分析

const { Option } = Select;

class EquityIndustryRisk extends PureComponent {
  constructor() {
    super();
    this.state = {
      industryType: '',
    };
  }
  componentDidMount() {
    const { equityIndustryRiskM } = this.props;
    dictionary;
    const { dictionary } = equityIndustryRiskM;
    const { industryTypeList } = dictionary;
    this.setState({ industryType: industryTypeList[0]?.code });
  }

  UNSAFE_componentWillReceiveProps(nextProps) {}

  onIndustryTypeChange = (e) => {
    const { equityIndustryRiskM } = this.props;
    const { searchData } = equityIndustryRiskM;
    if (searchData) {
      this.setState({ industryType: e });
    } else {
      message.info('查询条件已变更，请重新查询后再进行操作');
    }
  };

  render() {
    const { industryType } = this.state;
    const { equityIndustryRiskM } = this.props;
    dictionary;
    const { dictionary } = equityIndustryRiskM;
    const { industryTypeList } = dictionary;

    return (
      <div>
        <div style={{ paddingLeft: '20px' }}>
          行业分类：
          <Select style={{ width: '200px' }} value={industryType} onChange={this.onIndustryTypeChange}>
            {industryTypeList?.map((x) => (
              <Option key={x.id} value={x.code}>
                {x.value}
              </Option>
            ))}
          </Select>
        </div>
        <IndustryExposureDetail industryType={industryType} />
        <ProductAndBenchmarkIndustryExposure industryType={industryType} />
        <ProfitAnalysis industryType={industryType} />
      </div>
    );
  }
}
export default connect(({ equityIndustryRiskM }) => ({
  equityIndustryRiskM,
}))(EquityIndustryRisk);
